package cn.doitedu.day06

import org.apache.spark.Partitioner

/**
 * @Date 22.4.4
 * @Created by HANGGE
 * @Description
 */
class  MyPartitioner extends  Partitioner {
  var p:Int = _
  def this(p:Int) {
    this()
    this.p = p
  }
  override def numPartitions: Int = p

  override def getPartition(key: Any): Int = {
    val str = key.asInstanceOf[String]
    if (str.equals("a")||str.equals("b")){
      1
    }else{
      0
    }
  }
}
